#include "stdafx.h"

#include "Game.h"

Game::Game()
	: mCurrentMode(-1)
{
}

Game::~Game()
{
}

void Game::Init()
{
	Login * login = new Login;
	GamePlay * play = new GamePlay;

	mGameModes[eGameMode::LOGIN] = login;
	mGameModes[eGameMode::GAMEPLAY] = play;

	ChangeMode(eGameMode::GAMEPLAY);
}

void Game::Update()
{
	if (mCurrentMode != -1)
		mGameModes[mCurrentMode]->Update();
}

void Game::Shutdown()
{
	if (mCurrentMode != -1)
		mGameModes[mCurrentMode]->Shutdown();

	delete mGameModes[eGameMode::LOGIN];
	delete mGameModes[eGameMode::GAMEPLAY];
}

void Game::ChangeMode(int mode)
{
	if (mCurrentMode == mode)
		return ;

	if (mCurrentMode != -1)
		mGameModes[mCurrentMode]->Shutdown();

	mCurrentMode = mode;

	mGameModes[mCurrentMode]->Init();
}
